package com.ruoyi.wechat.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.DispatcherType;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 过滤器配置
 * </p>
 *
 * @author YinHeng
 * @since 2024/2/26
 */
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean bodyPrintFilter() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        List<String> urlPatterns = new ArrayList<>();
        urlPatterns.add("/*");
        filterRegistrationBean.setFilter(new RequestFilter());
        filterRegistrationBean.setOrder(Integer.MIN_VALUE);
        filterRegistrationBean.setUrlPatterns(urlPatterns);
        filterRegistrationBean.setDispatcherTypes(DispatcherType.REQUEST);
        return filterRegistrationBean;
    }
}

